﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Xml.Serialization;
using System.Data.OracleClient;
using System.Data;

namespace FieldUpdater.Classes
{
    public class OracleConnection
    {
        public const string TableSelect = "SELECT {0} FROM {1} WHERE {2}='{3}'";
        public const string ValuesSelect = "SELECT DISTINCT {1} FROM {0} ORDER BY {1}";

        public string ColumnName { get; set; }
        public string ConnectionString { get; set; }
        public string TableName { get; set; }
        public string SourceColumn { get; set; }
        public string TargetColumns { get; set; }
    }

    public class FieldAssociationCollection
    {
        public SerializableDictionary<string, OracleConnection> OracleConnections = new SerializableDictionary<string, OracleConnection>();
        public List<FieldAssociation> Associations = new List<FieldAssociation>();

        public override string ToString()
        {
            return Global.SerializeObject<FieldAssociationCollection>(this);
        }

        public static FieldAssociationCollection FromString(string xmlString)
        {
            try
            {
                return Global.DeserializeObject<FieldAssociationCollection>(xmlString);
            }
            catch
            {
                return new FieldAssociationCollection();
            }
        }
    }
}